<!-- This comment will put IE 6, 7 and 8 in quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>shark::MultiNomialDistribution Class Reference</title>
<script type="text/javaScript" src="search/search.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3.0.1/es5/tex-mml-chtml.js"></script>
<script src="../../mlstyle.js"></script>
<link href="../css/besser.css" rel="stylesheet" type="text/css"/>
</head>
<!-- pretty cool: each body gets an id tag which is the basename of the web page  -->
<!--              and allows for page-specific CSS. this is client-side scripted, -->
<!--              so the id will not yet show up in the served source code -->
<script type="text/javascript">
    jQuery(document).ready(function () {
        var url = jQuery(location).attr('href');
        var pname = url.substr(url.lastIndexOf("/")+1, url.lastIndexOf(".")-url.lastIndexOf("/")-1);
        jQuery('#this_url').html('<strong>' + pname + '</strong>');
        jQuery('body').attr('id', pname);
    });
</script>
<body>
    <div id="shark_old">
        <div id="wrap">
            <div id="header">
                <div id="site-name"><a href="../../sphinx_pages/build/html/index.html">Shark machine learning library</a></div>
                <ul id="nav">
                    <li >
                        <a href="../../sphinx_pages/build/html/rest_sources/installation.html">Installation</a>
                    </li>
		    <li >
                        <a href="../../sphinx_pages/build/html/rest_sources/tutorials/tutorials.html">Tutorials</a>
                    </li>
		    <li >
                        <a href="../../sphinx_pages/build/html/rest_sources/benchmark.html">Benchmarks</a>
                    </li>
                    <li class="active">
                        <a href="classes.html">Documentation</a>
                        <ul>
                            <li class="first"></li>
                            <li><a href="../../sphinx_pages/build/html/rest_sources/quickref/quickref.html">Quick references</a></li>
                            <li><a href="classes.html">Class list</a></li>
                            <li class="last"><a href="group__shark__globals.html">Global functions</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </div>
<div id="doxywrapper">
<!--
    <div id="global_doxytitle">Doxygen<br>Documentation:</div>
-->
    <div id="navrow_wrapper">
<!-- Generated by Doxygen 1.9.8 -->
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceshark.html">shark</a></li><li class="navelem"><a class="el" href="classshark_1_1_multi_nomial_distribution.html">MultiNomialDistribution</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="classshark_1_1_multi_nomial_distribution-members.html">List of all members</a> &#124;
<a href="#pub-methods">Public Member Functions</a>  </div>
  <div class="headertitle"><div class="title">shark::MultiNomialDistribution Class Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Implements a multinomial distribution.  
 <a href="classshark_1_1_multi_nomial_distribution.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="_multi_nomial_distribution_8h_source.html">shark/Statistics/Distributions/MultiNomialDistribution.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:aa682441c740b382d8dbecf718bc26815" id="r_aa682441c740b382d8dbecf718bc26815"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_multi_nomial_distribution.html#aa682441c740b382d8dbecf718bc26815">MultiNomialDistribution</a> ()</td></tr>
<tr class="separator:aa682441c740b382d8dbecf718bc26815"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a56cfc712e7a89fc5c8823d2877e2a7d8" id="r_a56cfc712e7a89fc5c8823d2877e2a7d8"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_multi_nomial_distribution.html#a56cfc712e7a89fc5c8823d2877e2a7d8">MultiNomialDistribution</a> (RealVector const &amp;<a class="el" href="classshark_1_1_multi_nomial_distribution.html#a16f80a1746538bcddf35222aba064f00">probabilities</a>)</td></tr>
<tr class="memdesc:a56cfc712e7a89fc5c8823d2877e2a7d8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructor.  <br /></td></tr>
<tr class="separator:a56cfc712e7a89fc5c8823d2877e2a7d8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac13b2e76fdc95f2b115a33507b5b3b52" id="r_ac13b2e76fdc95f2b115a33507b5b3b52"><td class="memTemplParams" colspan="2">template&lt;typename Archive &gt; </td></tr>
<tr class="memitem:ac13b2e76fdc95f2b115a33507b5b3b52"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classshark_1_1_multi_nomial_distribution.html#ac13b2e76fdc95f2b115a33507b5b3b52">serialize</a> (Archive &amp;ar, const unsigned int version)</td></tr>
<tr class="memdesc:ac13b2e76fdc95f2b115a33507b5b3b52"><td class="mdescLeft">&#160;</td><td class="mdescRight">Stores/Restores the distribution from the supplied archive.  <br /></td></tr>
<tr class="separator:ac13b2e76fdc95f2b115a33507b5b3b52"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a16f80a1746538bcddf35222aba064f00" id="r_a16f80a1746538bcddf35222aba064f00"><td class="memItemLeft" align="right" valign="top">RealVector const &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_multi_nomial_distribution.html#a16f80a1746538bcddf35222aba064f00">probabilities</a> () const</td></tr>
<tr class="memdesc:a16f80a1746538bcddf35222aba064f00"><td class="mdescLeft">&#160;</td><td class="mdescRight">Accesses the probabilityvector defining the distribution.  <br /></td></tr>
<tr class="separator:a16f80a1746538bcddf35222aba064f00"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af0528dd743cf80cb472af71f7c5dd92d" id="r_af0528dd743cf80cb472af71f7c5dd92d"><td class="memItemLeft" align="right" valign="top">RealVector &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_multi_nomial_distribution.html#af0528dd743cf80cb472af71f7c5dd92d">probabilities</a> ()</td></tr>
<tr class="memdesc:af0528dd743cf80cb472af71f7c5dd92d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Accesses a mutable reference to the probability vector defining the distribution. Allows for l-value semantics.  <br /></td></tr>
<tr class="separator:af0528dd743cf80cb472af71f7c5dd92d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1148b3503fe2227a20ebe3b3abc8d6fe" id="r_a1148b3503fe2227a20ebe3b3abc8d6fe"><td class="memTemplParams" colspan="2">template&lt;class randomType &gt; </td></tr>
<tr class="memitem:a1148b3503fe2227a20ebe3b3abc8d6fe"><td class="memTemplItemLeft" align="right" valign="top">result_type&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classshark_1_1_multi_nomial_distribution.html#a1148b3503fe2227a20ebe3b3abc8d6fe">operator()</a> (randomType &amp;rng) const</td></tr>
<tr class="memdesc:a1148b3503fe2227a20ebe3b3abc8d6fe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Samples the distribution.  <br /></td></tr>
<tr class="separator:a1148b3503fe2227a20ebe3b3abc8d6fe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a930effbb103135e41bb94dee25e7247e" id="r_a930effbb103135e41bb94dee25e7247e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_multi_nomial_distribution.html#a930effbb103135e41bb94dee25e7247e">update</a> ()</td></tr>
<tr class="separator:a930effbb103135e41bb94dee25e7247e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Implements a multinomial distribution. </p>
<p>A multinomial distribution is a discrete distribution with states 0,...,N-1 and probabilities p_i for state i with sum_i p_i = 1. This implementation uses the fast alias method (Kronmal and Peterson,1979) to draw the numbers in constant time. Setup is O(N) and also quite fast. It is advisable to use this method to draw many numbers in succession.</p>
<p>The idea of the alias method is to pair a state with high probability with a state with low probability. A high probability state can in this case be included in several pairs. To draw, first one of the states is selected and afterwards a coin toss decides which element of the pair is taken. </p>

<p class="definition">Definition at line <a class="el" href="_multi_nomial_distribution_8h_source.html#l00052">52</a> of file <a class="el" href="_multi_nomial_distribution_8h_source.html">MultiNomialDistribution.h</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="aa682441c740b382d8dbecf718bc26815" name="aa682441c740b382d8dbecf718bc26815"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa682441c740b382d8dbecf718bc26815">&#9670;&#160;</a></span>MultiNomialDistribution() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">shark::MultiNomialDistribution::MultiNomialDistribution </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="_multi_nomial_distribution_8h_source.html#l00056">56</a> of file <a class="el" href="_multi_nomial_distribution_8h_source.html">MultiNomialDistribution.h</a>.</p>

</div>
</div>
<a id="a56cfc712e7a89fc5c8823d2877e2a7d8" name="a56cfc712e7a89fc5c8823d2877e2a7d8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a56cfc712e7a89fc5c8823d2877e2a7d8">&#9670;&#160;</a></span>MultiNomialDistribution() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">shark::MultiNomialDistribution::MultiNomialDistribution </td>
          <td>(</td>
          <td class="paramtype">RealVector const &amp;&#160;</td>
          <td class="paramname"><em>probabilities</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Constructor. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">probabilities</td><td>Probability vector </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="_multi_nomial_distribution_8h_source.html#l00060">60</a> of file <a class="el" href="_multi_nomial_distribution_8h_source.html">MultiNomialDistribution.h</a>.</p>

<p class="reference">References <a class="el" href="classshark_1_1_multi_nomial_distribution.html#a930effbb103135e41bb94dee25e7247e">update()</a>.</p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a1148b3503fe2227a20ebe3b3abc8d6fe" name="a1148b3503fe2227a20ebe3b3abc8d6fe"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1148b3503fe2227a20ebe3b3abc8d6fe">&#9670;&#160;</a></span>operator()()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class randomType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">result_type shark::MultiNomialDistribution::operator() </td>
          <td>(</td>
          <td class="paramtype">randomType &amp;&#160;</td>
          <td class="paramname"><em>rng</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Samples the distribution. </p>

<p class="definition">Definition at line <a class="el" href="_multi_nomial_distribution_8h_source.html#l00090">90</a> of file <a class="el" href="_multi_nomial_distribution_8h_source.html">MultiNomialDistribution.h</a>.</p>

<p class="reference">References <a class="el" href="namespaceshark_1_1random.html#ada5e9e6fd77534e1d99479213e5fed50">shark::random::coinToss()</a>, and <a class="el" href="namespaceshark_1_1random.html#aa64d4174eaf7111b03e0504eaa56b666">shark::random::discrete()</a>.</p>

</div>
</div>
<a id="af0528dd743cf80cb472af71f7c5dd92d" name="af0528dd743cf80cb472af71f7c5dd92d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af0528dd743cf80cb472af71f7c5dd92d">&#9670;&#160;</a></span>probabilities() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">RealVector &amp; shark::MultiNomialDistribution::probabilities </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Accesses a mutable reference to the probability vector defining the distribution. Allows for l-value semantics. </p>
<p>ATTENTION: If the reference is altered, update needs to be called manually. </p>

<p class="definition">Definition at line <a class="el" href="_multi_nomial_distribution_8h_source.html#l00084">84</a> of file <a class="el" href="_multi_nomial_distribution_8h_source.html">MultiNomialDistribution.h</a>.</p>

</div>
</div>
<a id="a16f80a1746538bcddf35222aba064f00" name="a16f80a1746538bcddf35222aba064f00"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a16f80a1746538bcddf35222aba064f00">&#9670;&#160;</a></span>probabilities() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">RealVector const  &amp; shark::MultiNomialDistribution::probabilities </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Accesses the probabilityvector defining the distribution. </p>

<p class="definition">Definition at line <a class="el" href="_multi_nomial_distribution_8h_source.html#l00076">76</a> of file <a class="el" href="_multi_nomial_distribution_8h_source.html">MultiNomialDistribution.h</a>.</p>

</div>
</div>
<a id="ac13b2e76fdc95f2b115a33507b5b3b52" name="ac13b2e76fdc95f2b115a33507b5b3b52"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac13b2e76fdc95f2b115a33507b5b3b52">&#9670;&#160;</a></span>serialize()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename Archive &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void shark::MultiNomialDistribution::serialize </td>
          <td>(</td>
          <td class="paramtype">Archive &amp;&#160;</td>
          <td class="paramname"><em>ar</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const unsigned int&#160;</td>
          <td class="paramname"><em>version</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Stores/Restores the distribution from the supplied archive. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">ar</td><td>The archive to read from/write to. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">version</td><td>Currently unused. </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="_multi_nomial_distribution_8h_source.html#l00069">69</a> of file <a class="el" href="_multi_nomial_distribution_8h_source.html">MultiNomialDistribution.h</a>.</p>

</div>
</div>
<a id="a930effbb103135e41bb94dee25e7247e" name="a930effbb103135e41bb94dee25e7247e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a930effbb103135e41bb94dee25e7247e">&#9670;&#160;</a></span>update()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void shark::MultiNomialDistribution::update </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="_multi_nomial_distribution_8h_source.html#l00102">102</a> of file <a class="el" href="_multi_nomial_distribution_8h_source.html">MultiNomialDistribution.h</a>.</p>

<p class="reference">Referenced by <a class="el" href="classshark_1_1_multi_nomial_distribution.html#a56cfc712e7a89fc5c8823d2877e2a7d8">MultiNomialDistribution()</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>include/shark/Statistics/Distributions/<a class="el" href="_multi_nomial_distribution_8h_source.html">MultiNomialDistribution.h</a></li>
</ul>
</div><!-- contents -->
</div>
</body>
</html>
